import { Component, OnDestroy, OnInit } from "@angular/core";
import { InnerMqService } from "src/app/rx/service/inner-mq.service";
import { InnerMqClient } from "src/app/rx/client/inner-mq.client";
import { Topic } from "src/app/rx/topic";

@Component({
	selector: 'app-test-a',
	templateUrl: 'test-a.component.html',
	styleUrls: ['test-a.component.scss'],
})
export class TestAComponent implements OnInit, OnDestroy {

	private client!: InnerMqClient;

	constructor(
		private innerMqService: InnerMqService,
	) {
	}

	ngOnInit(): void {
		this.client = this.innerMqService.createClient();
		this.client.sub(Topic.MY_TP_1, (res) => {
			console.log(res);
		});
	}

	ngOnDestroy(): void {
		this.innerMqService.destroyClient(this.client);
		console.log('test-a销毁客户端');
	}

}
